﻿
using Red.Controls.Converters;
using System.Windows.Controls;
using System.Windows.Data;

namespace Red.Controls.DataDriven
{
    /// <summary>
    ///     Data-aware check-box
    /// </summary>
    [InteropControl("Bool", "bool")]
    public class DataCheckBox : CheckBox
    {
        public DataCheckBox()
        {
            SetBinding( IsCheckedProperty, new Binding( "Value" )
            { 
                Mode = BindingMode.TwoWay,
                Converter = new BoolStringConverter()
            } );

            SetBinding( IsEnabledProperty, new Binding( "IsReadOnly" )
            {
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Converter = new BoolInverter()
            } );
        }
    }
}
